package com.jinyou.utils.common;

import java.util.ArrayList;
import java.util.List;

//数组工具
public class JYArrayUtils {
    //将数组转换为list
    public static List<String> convertArrayStringToList(String array, String splitChar) {
        if (ValidateUtil.isNull(array)) {
            return null;
        }
        if (ValidateUtil.isNull(splitChar)) {
            splitChar = ",";
        }
        String[] arr;
        try {
            arr = array.split(splitChar);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        List<String> list = new ArrayList<String>();
        for (int i = 0; i < arr.length; i++) {
            if (ValidateUtil.isNull(arr[i])) {
                continue;
            }
            list.add(arr[i]);
        }
        return list;
    }

    //将数组转换为list
    public static List<String> convertArrayStringToList(String array) {
        return convertArrayStringToList(array, ",");
    }


}
